package com.thwcompany.thread;
/**
 * Created by IntelliJ IDEA2021.3
 *
 * @Author: Tenghw
 * @Date: 2022/04/06  11:09
 * @Description:
 */
@SuppressWarnings("all")
public class MainTest {
    //============================================================================
    public static void main0(String[] args) {
        Thread thread1 = new Thread(new RunnableOneImp());
        thread1.start();
        for (int b = 0; b < 5; b++) {
            System.out.println("当前线程为：" + Thread.currentThread().getName() + ",b=" + b);
            if (b == 2) {
                try {
                    thread1.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
  //============================================================================
    public static void main1(String[] args) {
        Thread thread1 = new Thread(new RunnableOneImp());
        thread1.start();
        for (int b = 0; b < 5; b++) {
            System.out.println("当前线程为：" + Thread.currentThread().getName() + ",b=" + b);
            try {
                Thread.sleep(1001);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    //============================================================================
    public static void main2(String[] args) {
        Thread thread1 = new Thread(new RunnableOneImp());
        thread1.start();
        for (int b = 0; b < 5; b++) {
            if (b == 2) {
            System.out.println("礼让一次：当前线程为：" + Thread.currentThread().getName() + ",b=" + b);
                Thread.yield();
            }else{
                System.out.println("当前线程为：" + Thread.currentThread().getName() + ",b=" + b);
            }
        }
    }
    //============================================================================
    public static void main(String[] args) {
    boolean b=false;
    if(b){
        System.out.println(1);
    }else {
        System.out.println(2);
    }
    }

}